<template>
  <div class="recipe-content">
    <div :class="isCustom ? 'check_content_state' : ''" class="proposal_content">
      <div v-for="(recommendRecipe, index) in diets" :key="index" class="proposal_list">
        <div v-if="isCustom" class="shade-editor">
          <img src="../../../../../../assets/img/editor-w.png" alt="" @click="diyRecipe(recommendRecipe)">
          <img src="../../../../../../assets/img/del_recipe.png" alt="" @click="delRecipe(recommendRecipe)">
        </div>
        <div class="pro_img">
          <el-image :src="recommendRecipe.thumbnail">
            <div slot="error" class="image-slot">
              <i class="el-icon-picture-outline" />
            </div>
          </el-image>
        </div>
        <div class="pro_num">
          {{ recommendRecipe.dosage }}{{ recommendRecipe.unit }} <span v-if="+recommendRecipe.material_energy !== 0">{{ recommendRecipe.material_energy }}</span>
        </div>
        <div class="pro_name">
          {{ recommendRecipe.material_name }}
        </div>
      </div>
      <div v-if="isCustom" class="add-food proposal_list">
        <img v-if="diets.length > 0" src="../../../../../../assets/img/add.png" alt="" @click="addRecipe(diets[0].meal_time)">
        <img v-else src="../../../../../../assets/img/add.png" alt="" @click="addRecipe('')">
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    diets: {
      type: Array,
      default: () => {
        return []
      }
    },
    isCustom: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {}
  },
  created() {},
  methods: {
    diyRecipe(recipe) {
      this.$emit('popDiyRecipe', recipe)
    },
    addRecipe(mealTime) {
      this.$emit('popAddRecipe', mealTime)
    },
    delRecipe(recipe) {
      this.$emit('delRecipe', recipe)
    }
  }
}
</script>
<style>
.proposal_list{
  display:inline-block;
  text-align:center;
}
.pro_img img {
  width:80px;
  height:auto;
}
.proposal_content{
  padding:10px ;
  display: inline-block;
}
.proposal_content.check_content_state:hover{
  border: 1px solid #d9d9d9;
}
.proposal_content.check_content_state:hover .add-food{
  opacity: 1;
}
.proposal_list{ 
  margin-right: 20px;
  display:inline-block;
  text-align:center;
  position: relative;
  cursor:pointer;
  vertical-align: middle;
}
.proposal_content .proposal_list:last-child {
  margin-right: 0
}
.pro_name{
  font-size: 13px;
  color: #161616;
  padding-top: 4px;
}
.pro_num {
  font-size: 10px;
  color: #fff; 
  background: #1eba56; 
  border-radius: 20px;
  padding: 1px 5px;
  min-width: 86px;
}
.shade-editor{
  opacity: 0;
  position:  absolute;
  background: rgba(0, 0, 0, 0.5);
  width:  100%;
  height:  100%;
  line-height:102px;
  -webkit-border-radius:4px;
  -moz-border-radius:4px;
  border-radius:4px;
  z-index: 999;
}
.shade-editor:hover{
  opacity: 1;
}
.shade-editor img{
  width: 20px;
  height:20px;
  margin: 0 6px;
}
.add-food img{
  width: 50px;
  height:50px;
  vertical-align: middle;
  margin-left: 60px;
  font-size: 16px;
  color: #1296db;
}
.add-food{
  line-height: 102px;
  opacity: 0;
}
.image-slot {
  width: 80px;
  height: 52px;
  line-height: 52px;
  background: #f5f7fa;
}
</style>
